﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Collections.Specialized;

namespace SqlMembershiProviderExtended
{
    
    public class MembershipSegment
    {
        public string Name { get; set; }
        public int Id { get; set; }
    }
    public class MembershipUserGroup
    {
    }
    public class MembershipSegmentGroup
    {
    }
    public class MembershipSegmentGroupCollection
    {
    }
    public class MembershipSegmentCollection : IEnumerable<MembershipSegment>, IDisposable
    {
        private Dictionary<int,MembershipSegment> _segmentCollection;
        
        public MembershipSegmentCollection( )
        {
            _segmentCollection = new Dictionary<int, MembershipSegment>( );
        }
        //Indexador
        public MembershipSegment this[int index]
        {
            get { return _segmentCollection[index]; }
            set { _segmentCollection[index] = value;}
        }
        public void Add( MembershipSegment segment )
        {
            _segmentCollection.Add( segment.Id, segment );
        }

        //Enumeradores generico y normal.
        public IEnumerator<MembershipSegment> GetEnumerator( )
        {
            foreach( KeyValuePair<int, MembershipSegment> item in _segmentCollection )
            {
                yield return item.Value;
            }
        }
        IEnumerator IEnumerable.GetEnumerator( )
        {
            foreach( KeyValuePair<int, MembershipSegment> item in _segmentCollection )
            {
                yield return item.Value;
            }
        }
        //Dispose.
        public void Dispose( )
        {
            _segmentCollection = null;
        }
  
    }
    
}
